import pandas as pd
pd.set_option ('display.unicode.east_asian_width', True)
df = pd.read_excel('产品订单信息表.xlsx')
df1 = pd.crosstab(index=df['性别'],columns=df['产品类型'])
print('统计性别和商品类型交叉频数的数据df1: \n',df1)
df2 = pd.crosstab(index=df['性别'],columns=df['产品类型'], margins=True)
print('统计和汇总性别和商品类型交叉频数的数据df2: \n',df2)
df3 = pd.crosstab(index=df['性别'],columns=df['产品类型'], margins=True, normalize=True)
print('统计和汇总性别和商品类型交叉频率的数据df3: \n',df3)
df4 = pd.crosstab(index=df['性别'],columns=df['产品类型'], margins=True, margins_name='总数',normalize='index')
print('按行统计和汇总性别和商品类型交叉频数的数据df4:\n',df4)